Skip to content

fixed head requests throwing errors for express 3.x - #75

Closed
trevorah wants to merge 1 commit into
expressjs:masterfrom
trevorah:master
Closed

fixed head requests throwing errors for express 3.x#75
trevorah wants to merge 1 commit into
expressjs:masterfrom
trevorah:master

Conversation

@trevorah

Copy link
Copy Markdown

In express 3.x, any HEAD request that uses express-session will throw a 500 error.

This is because express/lib/response.js calls this.end(null, encoding) if the request is a HEAD request (see closest blame here).

As the HEAD request just gets the headers for a particular resource, then the content length can also be set. This unfortunately means that the res.end patch attempts to create a new Buffer(null) which throws (usually when node/lib/buffer.js getting the length property of null).

This PR fixes it, with an extra test for res.end(undefined) just to be sure.

@dougwilson dougwilson added the bug label Aug 18, 2014
@dougwilson dougwilson self-assigned this Aug 18, 2014
@dougwilson

Copy link
Copy Markdown
Contributor

I can't wait to get this dumb patching crap into it's own module :) It's in progress, haha. I'm fixing this now.

@dougwilson

Copy link
Copy Markdown
Contributor

@trevorah can you verify npm install expressjs/session fixes your issue?

@trevorah

Copy link
Copy Markdown
Author

Yep, that fixes it and everything else is still working.

@dougwilson

Copy link
Copy Markdown
Contributor

great :) i'll be bundled with a new express 3 today

@trevorah

Copy link
Copy Markdown
Author

hooray!

@aesopwolf

Copy link
Copy Markdown

Thank you, thank you, thank you! Was debugging this all morning.

@expressjs expressjs locked and limited conversation to collaborators Sep 28, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants